import java.util.Random;

public class Test {

    static long sum1=0;
    static long sum2=0;
    public static void main(String[] args) throws InterruptedException {
        Random random=new Random();
        int[] arr=new int[10000000];
        for (int i = 0; i < 10000000; i++) {
            arr[i]=random.nextInt(100)+1;
        }
        long startTime = System.currentTimeMillis();
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 10000000; i+=2) {
                sum1+=arr[i];
            }
        });
        Thread t2 = new Thread(()->{
            for (int i = 1; i < 10000000; i+=2) {
                sum2+=arr[i];
            }
        });
        System.out.println(t1.getState());
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        long endTime = System.currentTimeMillis();
        System.out.println(" "+sum1);
        System.out.println(" "+sum2);
        System.out.println(sum1+sum2);
        System.out.println((endTime-startTime)+"ms");
    }
}
